package com.higgins.client;

import com.higgins.client.agentapp.tabs.AdvertisedJobsTab;
import com.higgins.client.agentapp.tabs.CorrespondenceTab;
import com.higgins.client.agentapp.tabs.JobSitesTab;
import com.higgins.client.agentapp.tabs.SettingsTab;
import com.higgins.client.tabs.CoveringLetterTab;
import com.higgins.client.tabs.RecipientTab;
import com.higgins.client.tabs.StrategyTab;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.logical.shared.SelectionEvent;
import com.google.gwt.event.logical.shared.SelectionHandler;
import com.google.gwt.user.client.ui.RootLayoutPanel;
import com.google.gwt.user.client.ui.TabPanel;
import com.google.gwt.user.client.ui.VerticalPanel;

/**
 * Entry point classes define <code>onModuleLoad()</code>.
 */
public class AgentApp implements EntryPoint {

	public void onModuleLoad() {
		TabPanel tabPanel = new TabPanel();
		tabPanel.setSize("200em","100em");
		
		final AdvertisedJobsTab advertisedJobsTab = new AdvertisedJobsTab();
		tabPanel.add(advertisedJobsTab, "Advertised Jobs");
		advertisedJobsTab.update();
		
		final CorrespondenceTab correspondenceTab = new CorrespondenceTab();
		tabPanel.add(correspondenceTab, "Correspondence");

		final SettingsTab settingsTab = new SettingsTab();
		tabPanel.add(settingsTab, "Settings");
		
		RootLayoutPanel.get().add(tabPanel);
		tabPanel.selectTab(0);
		tabPanel.addSelectionHandler(new SelectionHandler<Integer>()    {

			@Override
			public void onSelection(SelectionEvent<Integer> event) {
				int selection = event.getSelectedItem();
				
				switch (selection)	{
				case 0:
					advertisedJobsTab.update();
					break;
				case 1:
					correspondenceTab.update();
					break;
				case 2:
					settingsTab.update();
					break;
				}
			}
		});
	}
}
